package hapi.log;

import hapi.log.LogDecorator;

class BasicLogger implements Logger {
	
	var decorator:LogDecorator;
	
	private function new() {
		this.decorator = new NoLogDecorator();
	}
	
	public function redirectTraces() {
		haxe.Log.trace = this.trace;
	}
	
	public function log(msg:Dynamic) {
		throw "log method must be overriden";
	}
	
	public function trace(message : Dynamic, ?inf : haxe.PosInfos ) {
		log(decorator.decorate(message, inf));
	}
	
	public function applyDecorator(decorator) {
		if(decorator != null)
			this.decorator = decorator;
	}
}